{% extends 'base.html' %}

{% block title %}主页{% endblock %}

{% block header %}
<div class="d-flex justify-content-center">
    <form class="d-flex" role="search" action="{{ url_for('room.search') }}">
        <input class="form-control me-2" type="search" name="query" id="query"
            placeholder="请输入聊天室名称" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">搜索</button>
    </form>
</div>
{% endblock %}

{% block content %}
<table class="table">
    <tbody>
        {% if rooms %}
        {% for room in rooms %}
        <tr>
            <td class="align-middle">
                {{ room['name'] }}<sub>{{ room['username'] }}</sub>
            </td>
            <td class="align-middle">
                <a href="{{ url_for('room.join', room_id=room['id']) }}" class="btn btn-primary">点击加入</a>
            </td>
        </tr>
        {% endfor %}
        {% else %}
        <tr>
            <td class="align-middle text-center">
                未找到聊天室
            </td>
        </tr>
        {% endif %}
    </tbody>
</table>

{% endblock %}